﻿using System;
using System.Collections.Generic;
using System.Linq;

using SharedGenomics.Core;
using SharedGenomics.Domain;
using SharedGenomics.Workbench.Core;
using SharedGenomics.Workbench.PresentationModel;

namespace SharedGenomics.Workbench.Presenters
{
    public class JobOptionsPresenterFactory : IJobOptionsPresenterFactory
    {
        private readonly PresenterFactory _presenterFactory;

        public JobOptionsPresenterFactory(PresenterFactory presenterFactory)
        {
            this._presenterFactory = presenterFactory;
        }

        public IJobOptionsPresenter GetPresenterForJobType(JobSubmissionPTO jobSubmissionPresentationModel)
        {
            jobSubmissionPresentationModel.ThrowIfNull("jobSubmissionPresentationModel");
            IJobOptionsPresenter optionsPresenter = null;

            switch (jobSubmissionPresentationModel.SelectedJobType)
            {
                case JobType.PModel:
                    optionsPresenter = (IJobOptionsPresenter)this._presenterFactory.Get<ModelJobOptionsPresenter>(true);
                    break;
                case JobType.PCMH:
                    optionsPresenter = (IJobOptionsPresenter)this._presenterFactory.Get<CMHJobOptionsPresenter>();
                    break;
                default:
                    optionsPresenter = (IJobOptionsPresenter)this._presenterFactory.Get<EmptyJobOptionsPresenter>();
                    break;
            }

            optionsPresenter.PresentationModel = jobSubmissionPresentationModel;
            return optionsPresenter;
        }
    }
}
